package leetcode.editor.cn;

import java.util.HashMap;
import java.util.Map;

/**
 * 两数之和
 * @author qulq
 * @date 2025-02-24 21:38:46
 */
public class T1_TwoSum{
	 public static void main(String[] args) {
	 	 // 测试代码
	 	 Solution solution = new T1_TwoSum().new Solution();
	 }
	 
// 力扣代码
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int[] twoSum(int[] nums, int target) {
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < nums.length; i++) {
			if (map.containsKey(target - nums[i])) {
				return new int[]{i, map.get(target - nums[i])};
			}
			map.put(nums[i], i);
		}
		return new int[0];
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}